package com.ruoyi.user.job;

import com.ruoyi.common.core.cg.pojo.Group;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.user.service.GroupService;
import io.lettuce.core.RedisClient;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.logging.Logger;

@Component("job")
public class UserJob {
    @Autowired
    private GroupService groupService;
    @Bean
    public void updateGroupStateJob(){
        System.err.println("定时任务执行了");
        // 查询过期的团
        List<Integer> groupIdList = groupService.findByTime();
        if (groupIdList.size() > 0){
            // 修改拼团状态
            groupService.batchUpdateState(groupIdList);
            for (Integer id:groupIdList){
                System.out.println("修改了id为"+id+"的团的状态");
            }
        }
    }
}
